﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Gallio.Framework;
using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;

using jQuery.Validation.DataAnnotations;

namespace jQuery.Validation.Tests
{
    [TestFixture]
    public class AcceptAttributeTest
    {
        public static AcceptAttribute GetAttribute()
        {
            return new AcceptAttribute("csv");
        }


        [Test]
        [Row(".csv")]
        [Row("file.csv")]
        public void IsValidForCorrectStrings(string value)
        {
            AcceptAttribute attr = new AcceptAttribute("csv");
            Assert.IsTrue(attr.IsValid(value));
        }

        [Test]
        public void IsValidForNullValue()
        {
            Assert.IsTrue(GetAttribute().IsValid(null));
        }

        [Test]
        [Row("file.css")]
        [Row("csv")]
        [Row("file.csv123")]
        [Row("file.csv.ext")]
        public void IsNotValidForIncorrectStrings(string value)
        {
            Assert.IsFalse(GetAttribute().IsValid(value));
        }

        [Test]
        public void IsNotValidForDateObjects()
        {
            AcceptAttribute attr = new AcceptAttribute("csv");
            Assert.IsFalse(attr.IsValid(DateTime.Today));
        }

        [Test]
        public void IsNotValidForIntegerObjects()
        {
            AcceptAttribute attr = new AcceptAttribute("csv");
            Assert.IsFalse(attr.IsValid(123));
        }
    }
}
